import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 15.12.14
 * Time: 22:52
 * To change this template use File | Settings | File Templates.
 */
public class Employee implements  Serializable {


    private int id;
    private String name;
    private String surname;
    private String lastName;
    private Department department;
    private String phoneNumber;
    private String pay;
    //
    public Employee()
    {

        this.id = 0;
        this.name =null;
        this.surname=null;
        this.lastName = null;
        this.department =null;
        this.phoneNumber = null;
        this.pay = null;

    }

    public Employee (int id, String name,String surname, String lastname, String phone, String salary)
    {
        this.id=id;
        this.name =name;
        this.surname=surname;
        this.lastName = lastname;
        this.department =null;
        this.phoneNumber = phone;
        this.pay = salary;
    }


    public void setName(String name) {
        this.name = name;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public void setPay(String pay) {
        this.pay = pay;
    }

    public String getName() {
        return name;
    }

    public int getId()
    {
       return id;
    }

    public String getSurname() {
        return surname;
    }

    public String getLastName() {
        return lastName;
    }

    public Department getDepartment() {
        return department;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public String getPay() {
        return pay;
    }


    public String getInfo()
    {
        if(this.getDepartment()!=null)
        {
        return new String(name+ " "+ surname+" "+ lastName + " "+ department.getName());
        }
        else return new String(name+ " "+ surname+" "+ lastName + " "+ "без отдела") ;
    }

    public boolean equals(Employee d1)
    {

        if ((this.getDepartment()==null&&d1.getDepartment()==null)&&this.getName().equals(d1.getName())&&this.getSurname().equals(d1.getSurname())&&this.getLastName().equals(d1.getLastName())&&this.getPay().equals(d1.getPay())&&this.getPhoneNumber().equals(d1.getPhoneNumber()))
        {
            return true;
        }
        else
        {
            if(this.getDepartment()!=null&&d1.getDepartment()!=null)
            {
                if(this.getDepartment().getName().equals(d1.getDepartment().getName())&&this.getName().equals(d1.getName())&&this.getSurname().equals(d1.getSurname())&&this.getLastName().equals(d1.getLastName())&&this.getPay().equals(d1.getPay())&&this.getPhoneNumber().equals(d1.getPhoneNumber()))
                {return true;}
                else {return false;}
            }
            else{return false;}
        }
    }


}
